var t = getApp(), e = t.requirejs("core"), a = t.requirejs("biz/order")

t.requirejs("foxui");

Page({
    data: {
      icons: t.requirejs("icons"),
      page: 1,
      loading: false,
      loaded: false,
      type: 1,
      list: [],
      cancel: a.cancelArray,
      cancelindex: 0,
    },
    onLoad: function(t) { 
        var _this = this;
        e.get("member", {}, function(t) {
            _this.setData({
                customer: t.customer,
            })
        });
     },
    onShow: function() {
        this.setData({
            imgUrl: t.globalData.approot
        }),
        this.get_list();
        t.getCache("isIpx") ? this.setData({
            isIpx: !0,
            iphonexnavbar: "fui-iphonex-navbar",
            paddingb: "padding-b"
        }) : this.setData({
            isIpx: !1,
            iphonexnavbar: "",
            paddingb: ""
        })
    },
    get_list: function() {
        var t = this, type = t.data.type;
        t.setData({
            loading: true
        }), e.get("merch/order/get_list", {
            type: type,
            page: t.data.page,
        }, function(e) {
            var i = {
                loading: false,
                total: e.total,
                pagesize: e.pagesize,
                show: !0
            };
            e.list.length > 0 && (i.page = t.data.page + 1, i.list = t.data.list.concat(e.list), 
            e.list.length < e.pagesize && (i.loaded = true)), t.setData(i);
        });
    },
    tab: function(p) {
        var ty = Number(this.data.type),
            pe = Number(p.currentTarget.dataset.type);
        if(ty==pe) return false;
        if(wx.pageScrollTo){
            wx.pageScrollTo({
                scrollTop: 0,
                duration: 0
            })
        }
        this.setData({
            page: 1,
            list: [],
            loaded: false,
            type: pe,
        }), this.get_list();
    },
    onReachBottom: function() {
      this.data.loaded || this.data.list.length == this.data.total || this.get_list();
    },
    onPullDownRefresh: function() {
      wx.stopPullDownRefresh();
    },
    cancel: function(t) {
        var s = e.data(t).orderid;
        a.cancel(s, t.detail.value, "/store/order/index");
    },
    delete: function(t) {
        var s = e.data(t).type, i = e.data(t).orderid;
        a.delete(i, s, "/store/order/index", this);
    },
});